﻿using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace Demo
{
    /// <summary>
    /// 后台运行主框架
    /// </summary>
    public partial class BackstageRun : ObservableObject
    {
        Window_For_AddProtocol W_AddProtocol = null;


        /// <summary>
        /// 标准命令指令
        /// </summary>
        /// <param name="commandName"></param>
        [RelayCommand]
        public void Cmd(string commandName)
        {
            switch (commandName)
            {
                case "添加协议":
                    {
                        if (W_AddProtocol == null)
                        {
                            W_AddProtocol = new Window_For_AddProtocol();
                            W_AddProtocol.TellParent += Window_TellMe;
                        }
                        W_AddProtocol.Show();
                    }
                    break;
                case "Single测试":
                    {
                        MessageBox.Show(commandName);
                    }
                    break;
                case "整体测试Run":
                    {
                        MessageBox.Show(commandName);
                    }
                    break;
                case "整体测试Stop":
                    {
                        MessageBox.Show(commandName);
                    }
                    break;
                default:
                    MessageBox.Show(commandName);
                    break;
            }

        }

        private void Window_TellMe(object data)
        {
            switch (data)
            {
                case "Demo.Window_For_AddProtocol is Closing...":
                    {
                        if (W_AddProtocol != null)
                        {
                            W_AddProtocol = null;
                        }
                    }
                    break;
                default:
                    {
#if DEBUG
                        Debug.WriteLine(data); //还有什么要填写的，从调试的输出看看吧。 2024年3月8日14:51:52
#endif
                    }
                    break;
            }
            
        }
    }
}
